//-----------------Sonic CD Fire Gun Script-------------------//
// Yeah...

// Aliases
#alias Object.Value0	:	Object.Timer
#alias Object.Value1	:	Object.Delay
#alias Object[24].PropertyValue	:	HUD.CurrentTimePeriod

sub ObjectMain
	Object.Delay = Object.PropertyValue
	Object.Delay <<= 4
	Object.Timer++
	if Object.Timer == Object.Delay
		Object.Timer = 0
			PlayStageSFX(6, false)
			TempValue1  = Object.XPos
			TempValue1 += 0x100000

			TempValue2  = Object.YPos
			TempValue2 += 0x0000
			CreateTempObject(TypeName[FireBall], TempValue0, TempValue1, TempValue2)
			Object[TempObjectPos].DrawOrder =  3
			Object[TempObjectPos].PropertyValue =  1
			TempValue0++
	end if
end sub

sub ObjectDraw
	DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
end sub

sub ObjectStartup
	LoadSpriteSheet("R2/Objects2.gif")

	TempValue0 = HUD.CurrentTimePeriod
	TempValue1 = 182
	TempValue0 *= 17
	TempValue1 += TempValue0 
	SpriteFrame(-8, -16, 16, 32, TempValue1, 101)

	ArrayPos0 = 32
	while ArrayPos0 < 1056
		if Object[ArrayPos0].Type == TypeName[FireGunL]
			Object[ArrayPos0].DrawOrder = 4
			Object[ArrayPos0].Direction = FACING_LEFT
		end if
		ArrayPos0++
	loop
end sub

#alias 0	:	INK_NONE
#alias 1	:	INK_BLEND

// ========================
// Editor Subs
// ========================

sub RSDKEdit
	if editor.returnVariable == true
		switch editor.variableID
		case EDIT_VAR_PROPVAL // property value
		case 0 // property value
			checkResult = object.propertyValue
			break
		end switch
	else
		switch editor.variableID
		case EDIT_VAR_PROPVAL // property value
		case 0 // property value
			object.propertyValue = editor.variableValue
			break
		end switch
	end if
end sub

sub RSDKDraw
	Object.Direction = 1
	DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
	TempValue0 = 8; TempValue1 = 16; TempValue2 = 8; TempValue3 = 16;
	CallFunction(EditorHelpers_DrawHitbox)

	if editor.showGizmos == true
		editor.drawingOverlay = true

		TempValue0 = Object.XPos
		TempValue0 -= 0x40 0000

		DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, 255, 255)

		object.inkEffect = INK_BLEND
		DrawSpriteFX(1, FX_INK, TempValue0, Object.YPos)
		object.inkEffect = INK_NONE

		editor.drawingOverlay = false
	end if
end sub


sub RSDKLoad
	LoadSpriteSheet("R2/Objects2.gif")
	SpriteFrame(-8, -16, 16, 32, 182, 101)		// #0 - BrickBlock
	SpriteFrame(-17, -8, 33, 16, 166, 169)  	// #1 - I DON'T CARE HOW BIG THE ROOM IS, I CAST FIRE BALL!!

	SetVariableAlias(ALIAS_VAR_PROPVAL, "delay")
end sub